﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace Maticsoft.DBUtility
{
    public class SqlField : Attribute
    {
        private string _sqlcolumn;
        private SqlDbType _sqldbtypename;
        private int _length;
        
        /// <summary>
        /// 设置ORM映射
        /// </summary>
        /// <param name="sqlcolumn"></param>
        /// <param name="sqldbtypename"></param>
        /// <param name="length"></param>
        public SqlField(string sqlcolumn,SqlDbType sqldbtypename, int length)
        {
            _sqlcolumn = sqlcolumn;
            _sqldbtypename = sqldbtypename;
            _length = length;
        }

        /// <summary>
        /// 设置ORM映射
        /// </summary>
        /// <param name="sqlcolumn"></param>
        /// <param name="sqldbtypename"></param>
        public SqlField(string sqlcolumn, SqlDbType sqldbtypename)
        {
            _sqlcolumn = sqlcolumn;
            _sqldbtypename = sqldbtypename;
        }
        
        /// <summary>
        /// 获取表字段名称
        /// </summary>
        public string SqlColumn
        {
            get { return _sqlcolumn; }
        }

        /// <summary>
        /// 获取表字段数据类型
        /// </summary>
        public SqlDbType SqlDbTypeName
        {
            get { return _sqldbtypename; }
        }

        /// <summary>
        /// 数据长度
        /// </summary>
        public int Length
        {
            get { return _length; }
        }
    }
}
